[slug].vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <script lang='ts' setup>
  2. import { useCommonStore } from '@/stores/modules/common'
  3. import { Api } from '@/api/model/url'
  4. const route = useRoute()
  5. const commonStore = useCommonStore()
  6. const list = ref<any>([])
  7. const config = useRuntimeConfig()
  8. const { apiBaseSiteUrl } = config.public
  9. const slug = route.params.slug
  10. const { data: res } = await useAsyncData(
  11. 'category-detail',
  12. () =>
  13. $fetch(`${apiBaseSiteUrl}${Api.CategoryDetail}`, { params: { slug } }),
  14. )
  15. const seoData = res.value?.result
  16. const { data: res2 } = await useAsyncData(
  17. 'category-catalogue-list',
  18. () =>
  19. $fetch(`${apiBaseSiteUrl}${Api.CategoryCatalogueList}`, { params: { slug, pageNo: 1, pageSize: 4, state: 1, trend: '' } }),
  20. )
  21. list.value = res2.value?.result?.records || []
  22. const { openLoginAndDownloadModal } = useLoginAndDownLoadModal()
  23. async function clickLoginAndDownload(item: any) {
  24. try {
  25. commonStore.setDownloadCatalog(item)
  26. const { status } = await openLoginAndDownloadModal()
  27. if (status)
  28. location.reload()
  29. }
  30. catch (error) {
  31. console.log(error)
  32. }
  33. }
  34. const firstTitle = computed(() => {
  35. return seoData?.contentTitle ? handleTitle(seoData.contentTitle, 1) : ''
  36. })
  37. const secondTitle = computed(() => {
  38. return seoData?.contentTitle ? handleTitle(seoData.contentTitle, 2) : ''
  39. })
  40. function handleTitle(title: string | undefined, position: number) {
  41. if (!title)
  42. return ''
  43. // 先判断标题中是否带有&,获取第一个&之前的数据和之后的数据
  44. let firstPart = ''
  45. let secondPart = ''
  46. const index = title.indexOf('&')
  47. if (index !== -1) {
  48. firstPart = title.slice(0, index).trim()
  49. secondPart = title.slice(index + 1).trim()
  50. }
  51. else {
  52. // 如果没有&,返回第一个空格之前的数据和之后的数据
  53. const spaceIndex = title.indexOf(' ')
  54. if (spaceIndex !== -1) {
  55. firstPart = title.slice(0, spaceIndex).trim()
  56. secondPart = title.slice(spaceIndex + 1).trim()
  57. }
  58. }
  59. // 返回全部大写字母
  60. return position === 1 ? firstPart.toUpperCase() : secondPart.toUpperCase() || ''
  61. }
  62. </script>
  63. <template>
  64. <div>
  65. <div class=" bg-#0F0820 header">
  66. <div class=" w-1200-auto pos-relative text-center flex items-center justify-start h-600px bg-no-repeat bg-center">
  67. <h1 class="text-58px fw-800 text-#fff ls-2 custom-title-font">
  68. <span class="flex items-center">
  69. {{ firstTitle }}<svgo-flower class="w-44px h-44px !text-#FFFF66 ml-20px" />
  70. </span>
  71. <span class="flex items-center">
  72. <svgo-star-blue class="w-44px h-44px text-#1AC18E mr-20px" /> {{ secondTitle }}
  73. </span>
  74. </h1>
  75. <div class="pos-absolute right-0 bottom-76px w-426px h-340px header-img-bg flex justify-center items-center">
  76. <img :src="seoData.bannerImg" alt="" class="w-full h-390px object-contain mb-40px">
  77. </div>
  78. </div>
  79. </div>
  80. <div class="py-120px w-1200-auto text-center">
  81. <h2 class="text-36px fw-800 text-#333 !mb-20px custom-title-font">
  82. Our Latest Product <span class="custom-title-bg04">Catalogs</span>
  83. </h2>
  84. <div class="text-#999 text-22px mb-40px">
  85. Discover bestsellers and fresh arrivals tailored to your niche.
  86. </div>
  87. <div class="grid grid-cols-2 gap-64px text-left">
  88. <div v-for="item in list" :key="item.id">
  89. <business-categories-comp-item :item="item" @select="clickLoginAndDownload" />
  90. </div>
  91. </div>
  92. </div>
  93. <common-block-catalogs />
  94. <common-block-blog class="!pb-0" />
  95. <AppFooter />
  96. </div>
  97. </template>
  98. <style lang='less' scoped>
  99. .header{
  100. background-image: url('@/assets/images/catalogue_bg.png');
  101. background-position: center center;
  102. background-size: cover;
  103. .header-img-bg{
  104. background-image: url('@/assets/images/catalogue_bg_img.png');
  105. background-size: cover;
  106. background-position: center;
  107. }
  108. }
  109. </style>